package com.huawei.appmarket.service.store.awk.card;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.GradientDrawable.Orientation;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.card.base.normal.bean.NormalCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.foundation.ui.framework.widget.button.DownloadButton;
import com.huawei.appgallery.horizontalcard.api.card.BaseHorizontalItemCard;
import com.huawei.appmarket.service.store.awk.bean.VideoStreamListCardBean;
import com.huawei.appmarket.service.videostream.view.VideoStreamActivityProtocol;
import com.huawei.appmarket.service.videostream.view.VideoStreamActivityProtocol.Request;
import java.util.ArrayList;
import java.util.List;
import o.azb;
import o.cgz;
import o.chy;
import o.chz;
import o.cil;
import o.cjk;
import o.cjm;
import o.cjo;
import o.ckd;
import o.ckt;
import o.clp;
import o.dke;
import o.Logger;
import o.dof;
import o.doo;
import o.ContentManager;
import o.eho;
import o.emp;
import o.emt;
import o.CollectCheck;
import o.eqx;
import o.eqz;
import o.erq;
import o.evf;
import o.evk;
import o.ewm.c;
import o.ewm.d;
import o.ewm.e;
import o.ewm.j;
import o.ewm.n;
import o.fmw;

public class VideoStreamListCard extends BaseHorizontalItemCard implements eqz {
    private View ʻ;
    private String ʼ;
    private TextView ʽ;
    private RelativeLayout ˊॱ;
    private ImageView ˋ;
    private chz ˋॱ;
    private clp<? extends NormalCardBean> ˏॱ;
    private VideoStreamListCardBean ͺ;
    private int ॱˊ;
    private TextView ॱॱ;
    private int ॱᐝ;
    private TextView ᐝ;

    static class a {
        private a() {
        }

        public void ˎ(ImageView imageView) {
            if (evf.ˊ(imageView)) {
                imageView.setImageDrawable((Drawable) fmw.ˏ(imageView.getContext(), e.ꜞ, "drawable"));
            } else {
                imageView.setImageResource(e.ꜞ);
            }
        }

        public void ॱ(DownloadButton downloadButton) {
            if (evf.ˊ(downloadButton)) {
                new eho(c.ˊˊ, e.ﾞ, c.ᐝॱ).ॱ(downloadButton);
                return;
            }
            downloadButton.setButtonStyle(new dke(downloadButton.getContext(), -16777216, -16777216, e.ˋˊ, false, 0));
            downloadButton.setIsImmersion(true);
            downloadButton.ॱ();
        }
    }

    public VideoStreamListCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        ˋ((DownloadButton) view.findViewById(j.ﾞᐝ));
        this.ˋ = (ImageView) view.findViewById(j.ﹳᐝ);
        this.ᐝ = (TextView) view.findViewById(j.ﾟˊ);
        this.ॱॱ = (TextView) view.findViewById(j.ﹳˏ);
        this.ˊॱ = (RelativeLayout) view.findViewById(j.ﾞˊ);
        this.ʻ = view.findViewById(j.ﹳˎ);
        this.ʽ = (TextView) view.findViewById(j.ㆍʼ);
        ʽ(view);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        this.ͺ = (VideoStreamListCardBean) cardBean;
        String str = (String) this.ˋ.getTag();
        if (dof.ˋ(str) || !str.equals(this.ͺ.ʻᐝ())) {
            new a().ˎ(this.ˋ);
            this.ᐝ.setTextColor(this.ʼॱ.getResources().getColor(c.ʼ));
            new a().ॱ(ʽ());
            StringBuilder append = new StringBuilder().append(this.ͺ.v_());
            if (this.ͺ.ٴ() != 0) {
                Object ߴ = this.ͺ.ߴ();
                this.ॱॱ.setText(ߴ);
                append.append(ߴ);
            } else {
                this.ॱॱ.setText(this.ͺ.ˎͺ());
                append.append(this.ͺ.ˎͺ());
            }
            this.ˋ.setContentDescription(append.toString());
            this.ॱॱ.setTextColor(this.ʼॱ.getResources().getColor(c.ʼ));
            this.ᐝ.setText(this.ͺ.v_());
            this.ʼ = this.ͺ.ʿॱ();
            Context ˋ = ContentManager.getInstant().getContext();
            int dimensionPixelSize = ˋ.getResources().getDimensionPixelSize(d.ᐝᐝ);
            int dimensionPixelSize2 = ˋ.getResources().getDimensionPixelSize(d.ॱʻ);
            eqx.ॱ(ˋ, this.ͺ.ॱˌ(), null);
            eqx.ˏ(dimensionPixelSize, dimensionPixelSize2, this.ˋ, this.ͺ.ʻᐝ(), "image_default_icon", this, true);
            this.ˋ.setTag(this.ͺ.ʻᐝ());
            ˋ(this.ʽ, this.ͺ.ˋʻ());
            ᐝ(this.ॱॱ);
        } else if (Logger.ˎ()) {
            Logger.ˏ("VideoStreamListCard", "cardInfoBean.getBannerUrl_() = " + this.ͺ.ʻᐝ());
        }
    }

    public void ˋ(clp<? extends NormalCardBean> o_clp__extends_com_huawei_appgallery_foundation_card_base_normal_bean_NormalCardBean) {
        this.ˏॱ = o_clp__extends_com_huawei_appgallery_foundation_card_base_normal_bean_NormalCardBean;
        this.ॱˊ = 0;
    }

    public void ॱ(chz o_chz) {
        this.ˋॱ = o_chz;
        this.ॱˊ = 1;
    }

    public void ᐝ(int i) {
        this.ॱᐝ = i;
    }

    public void ॱ(Bitmap bitmap) {
        int i = -1;
        if (bitmap != null) {
            try {
                this.ʻ.setBackground(new GradientDrawable(Orientation.BOTTOM_TOP, new int[]{erq.ॱ(this.ʼ, bitmap), 0}));
                boolean ˏ = erq.ˏ(r2);
                this.ॱॱ.setAlpha(azb.ˋ(this.ʼॱ, d.ߺ));
                if (ˏ) {
                    this.ॱॱ.setAlpha(azb.ˋ(this.ʼॱ, d.ॱʿ));
                } else {
                    i = -16777216;
                }
                this.ᐝ.setTextColor(i);
                this.ॱॱ.setTextColor(i);
                i = c.ˊˊ;
                int i2 = e.ˋˊ;
                if (!evf.ˊ(ʽ())) {
                    ckd o_dke = new dke(this.ॱॱ.getContext(), this.ʼॱ.getResources().getColor(i), -16777216, i2, false, erq.ˊ(-1, 0.6f));
                    if (ʽ() != null) {
                        ʽ().setButtonStyle(o_dke);
                        ʽ().setIsImmersion(true);
                        ʽ().ॱ();
                    }
                }
            } catch (IllegalStateException e) {
                Logger.e("VideoStreamListCard", e.toString());
            }
        }
    }

    public void ॱ(final chy o_chy) {
        OnClickListener anonymousClass5 = new OnClickListener(this) {
            final /* synthetic */ VideoStreamListCard ˋ;

            public void onClick(View view) {
                if (!doo.ˊ(this.ˋ.ʼॱ)) {
                    evk.ˋ(this.ˋ.ʼॱ, this.ˋ.ʼॱ.getResources().getString(n.ʹˊ), 0).ˋ();
                } else if (view.getId() == j.ﹳᐝ) {
                    Request request = new Request();
                    cjo videoStreamActivityProtocol = new VideoStreamActivityProtocol();
                    cil.ˋ(this.ˋ.ʼॱ, new o.cim.a((VideoStreamListCardBean) this.ˋ.ˌ()).ˋ());
                    if (this.ˋ.ॱˊ == 0) {
                        List arrayList = new ArrayList(this.ˋ.ˏॱ.ॱ());
                        if (!CollectCheck.isEmpty(arrayList)) {
                            if (((VideoStreamListCardBean) arrayList.get(arrayList.size() - 1)).ﾞ() == 1) {
                                arrayList.remove(arrayList.size() - 1);
                            }
                            emp.ˎ().ˊ.put(Long.valueOf(this.ˋ.ˏॱ.ˎ()), arrayList);
                            request.ˎ(this.ˋ.ˏॱ.ˎ());
                            request.ॱ(true);
                            if (this.ˋ.ˏॱ.ॱ().size() < 13) {
                                request.ˊ(2);
                            } else {
                                request.ˊ(this.ˋ.ˏॱ.ˊ());
                            }
                            request.ˏ(this.ˋ.ˏॱ.ˋ());
                        } else {
                            return;
                        }
                    }
                    request.ˎ(this.ˋ.ˋॱ.ˏ);
                    request.ˏ(this.ˋ.ˋॱ.ʽ());
                    request.ˊ(this.ˋ.ˋॱ.ॱॱ());
                    request.ॱ(false);
                    List ॱ = emt.ॱ(this.ˋ.ˋॱ.ˎ);
                    this.ˋ.ॱᐝ = ॱ.indexOf(this.ˋ.ͺ);
                    emp.ˎ().ˊ.put(Long.valueOf(this.ˋ.ˋॱ.ˏ), ॱ);
                    request.ˋ(this.ˋ.ͺ.u_());
                    request.ˋ(this.ˋ.ॱᐝ);
                    videoStreamActivityProtocol.ˎ(request);
                    cjk.ˎ().ˋ(this.ˋ.ʼॱ, new cjm("video.stream.activity", videoStreamActivityProtocol));
                } else if (view.getId() == j.ﾞˊ) {
                    o_chy.ˏ(0, this.ˋ);
                }
            }
        };
        this.ˋ.setOnClickListener(new ckt(anonymousClass5));
        this.ˊॱ.setOnClickListener(new ckt(anonymousClass5));
    }
}
